
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php if (!session_id()) session_start(); ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>电子商务售前单</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" /><link href="demo.css" rel="stylesheet" type="text/css" />
    <script src="scripts/boot.js" type="text/javascript"></script>
	<style>

	</style>
    
</head>
<body >

 <fieldset id="fd1" style="border: 1px solid gray;height: 100px">
        <legend><span>搜索</span></legend>
        <div  id='fm1'>
        <div class="fieldset-body">
                客户代码:  <div class="mini-autocomplete" style="width:250px;"  popupWidth="400" textField="id" valueField="id"  id='U_CardCode' name='U_CardCode'
        url="/sale/getOCRDByCode" value="" text=""  onvaluechanged="">     
        <div property="columns">
            <div header="客户代码" field="id" width="30"></div>
            <div header="客户名称" field="text"></div>
        </div>
    </div>
    
         订单号： <input  id="orderId"  name="orderId" class="mini-textbox"  value="" />    
          买家姓名： <input id="U_Cstname"  name="U_Cstname" class="mini-textbox"  />
         售后客服： <input  id="U_DealerName"  name="U_DealerName" class="mini-textbox"   /><br/><br/>
    投诉日期范围      <input id="CreateDate1" name="CreateDate1" class="mini-datepicker" valueType="string" value="<?php echo date('Y-m-d',time()-86400*7);?>" />
       <input id="CreateDate2" name="CreateDate2" class="mini-datepicker" valueType="string" value="<?php echo date('Y-m-d');?>" />
                  
          <a class="mini-button" onclick="search" enabled="" >&nbsp;&nbsp;查询&nbsp;&nbsp;</a>   
        </div>
          </div>
          
    </fieldset>
  
   
    <div id="tabs1" class="mini-tabs" activeIndex="0" style="width:100%;margin-top: 5px;overflow:auto;" plain="false"
    buttons="#tabsButtons"
>
    <div title="售后明细" >
   
    <div id="datagrid1" class="mini-datagrid" style="height:300px;width: 100%;" 
        url="" idField="id"
        allowResize="true" 
        allowCellEdit="false" allowCellSelect="true" multiSelect="true"
        allowCellValid="true" oncellvalidation="onCellValidation" showPager='false'
    >
        <div property="columns">
        <div field="DocEntry" vtype=""   headerAlign="center"  >售前服务单序号
                <input property="editor" class="mini-textbox" style="width:100%;" />
          </div>  
        
        <div field="U_Priority"    headerAlign="center"  >优先级
                <input property="editor" class="mini-textbox" style="width:100%;" />
         </div>
           <div field="U_Cardcode"    headerAlign="center"  >客户代码
                <input property="editor" class="mini-textbox" style="width:100%;" />
         </div>  
         <div field="U_CardName"    headerAlign="center"  >客户名称
                <input property="editor" class="mini-textbox" style="width:100%;" />
         </div>  
          <div field="U_OrderId"    headerAlign="center"  >客户订单号
                <input property="editor" class="mini-textbox" style="width:100%;" />
         </div> 
          <div field="U_AccuPers" vtype="required;email"   headerAlign="center"  >买家姓名
                <input property="editor" class="mini-textbox" style="width:100%;" />
            </div>  
                 <div field="U_AccuDate"    headerAlign="center"  >投诉日期
                <input property="editor" class="mini-textbox" style="width:100%;" />
            </div> 
            <div field="U_AccuTime"    headerAlign="center"  >投诉时间
                <input property="editor" class="mini-textbox" style="width:100%;" />
            </div> 
                 
           <div field="U_QSummary" vtype="required;email"   headerAlign="center"  >问题总结
                <input property="editor" class="mini-textbox" style="width:100%;" />
            </div> 
            
         
               <div field="U_AccuQDtl"    headerAlign="center"  >投诉问题大类
                <input property="editor" class="mini-textbox" style="width:100%;" />
            </div> 
          <div field="U_ProSts"  width="100" renderer="onGenderRenderer" align="center" headerAlign="center">处理状态
                <input property="editor" class="mini-combobox" style="width:100%;" data="Genders"/>                
            </div>
             <div field="U_ItemCode"    headerAlign="center"  >物料代码
                <input property="editor" class="mini-textbox" style="width:100%;" />
            </div>    
            
             <div field="U_ItemName"    headerAlign="center"  >物料名称
                <input property="editor" class="mini-textbox" style="width:100%;" />
            </div>   
             <div field="U_ProEndDate"     >处理结束日期
                <input property="editor" class="mini-datepicker" style="width:100%;" valueType='string'   format="yyyy-MM-dd" />                
            </div>
            
      
      
      
            
            
               <div field="U_Dealer"    headerAlign="center"  >售后客服代码
                <input property="editor" class="mini-textbox" style="width:100%;" />
            </div>  
            
             <div field="U_DealerName"    headerAlign="center"  >售后客服名称
                <input property="editor" class="mini-textbox" style="width:100%;" />
            </div>  
            
             <div field="U_ProSts"    headerAlign="center"  renderer="onGenderU_AlloStatus"  >分配状态
                <input property="editor" class="mini-textbox" style="width:100%;" />
            </div> 
            
          
            
            
              
            <div field="U_AccuTel"    headerAlign="center"  >投诉人电话号码
                <input property="editor" class="mini-textbox" style="width:100%;" />
            </div>  
              
      
              <div field="U_CustAdr" vtype="required;email"   headerAlign="center"  >客户地址
                <input property="editor" class="mini-textbox" style="width:100%;" />
            </div> 
            
              
          
            
         
           
            
           

      
        </div>
    </div>
    
    
    </div>
    <!-- <div title="Tab2" iconCls="" >
        2
    </div> -->
</div>

  <div id='editForm1'>
    <!-- 售前问题描述：<textarea class="mini-textarea" emptyText="" style="width: 30%;margin-top: 5px" id='U_AccuQDtl' name='U_AccuQDtl'></textarea> <br />
    售后问题描述：<textarea class="mini-textarea" emptyText="" style="width: 30%;margin-top: 5px"id='U_AccuQDt2' name='U_AccuQDt2'></textarea> <br />
    领导意见&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;：<textarea class="mini-textarea" emptyText=""  id ='U_Suggest' name='U_Suggest' style="width: 30%;margin-top: 5px" ></textarea> <br /> 
     创建人&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: <input id="U_Suggest"  name="username" class="mini-textbox"   name='U_Suggest'  />
     --> 
    <br />
     

  </div>
</body>
<script type="text/javascript">
        mini.parse();
        var grid = mini.get("datagrid1");
        var Genders = [{'id':'1','text':'未完成'},{'id':'2','text':'已转到售后'},{'id':'3','text':'已完成'}];
        function onGenderRenderer(e) {
            for (var i = 0, l = Genders.length; i < l; i++) {
                var g = Genders[i];
                if (g.id == e.value) return g.text;
            }
            return "";
        }


 var U_AlloStatus = [{'id':'1','text':'未完成'},{'id':'2','text':'已转到售后'},{'id':'3','text':'已完成'}];
        
        function onGenderU_AlloStatus(e) {
           
            for (var i = 0, l = U_AlloStatus.length; i < l; i++) {
                var g = U_AlloStatus[i];
                if (g.id == e.value) return g.text;
            }
            return "";
        }

        
		var db = new mini.DataBinding();
        db.bindForm("editForm1", grid);
        function removeRow() {
            var rows = grid.getSelecteds();
            if (rows.length > 0) {
                grid.removeRows(rows, true);
            }
        }

        function getOrdermsg(){
			var row = grid.getSelected();
			var orderId = mini.get("orderId").getValue();
		
			 $.ajax({
	                url: "/sale/getOrderAjax",
	                data: { orderId: orderId },
	                type: "post",
	                dataType:'json',
	                success: function (data) {
		           		
	                	row.U_Phone=data.U_Phone;
	                	row.U_Cstname=data.U_Cstname;
	                	row.U_Address=data.U_address;
	                	row.U_UserCode='<?php echo $_SESSION['emp_no']?>';
	                	row.U_UserName='<?php echo $_SESSION['user_name']?>';
	                	grid.setSelected(row);
	                	grid.selects(0);
	                	
	                },
	                error: function (jqXHR, textStatus, errorThrown) {
	                    alert(jqXHR.responseText);
	                }
	            });

         }


        grid.on("cellclick", function (e) {
            var record = e.record,
                column = e.column,
                field = e.field,
                value = e.value;
            	if (field == "U_AccuDate") {
            		getOrdermsg();
          		  }

            });
        function save() {
            var data = grid.getChanges()[0];
             for(var i=0;i<data.length;i++){
            	/*data[i].U_AccuTel=data[i].U_Phone;
            	data[i].U_AccuPers=data[i].U_Cstname;
            	data[i].U_CustAdr=data[i].U_address;*/ 
            	data[i].U_OrderId=orderId;
                }  
             var json = mini.encode(data);
            
             if(data.U_AccuDate==null){
				mini.alert('售前日期不能为空');
				return ;
              }
           
            var form = new mini.Form("#fm1");            
            var fmdata = form.getData();      //获取表单多个控件的数据
    
            var fmjson = mini.encode(fmdata); //序列化成JSON
            alert(fmjson);return ;
            mini.mask({
                el: document.body,
                cls: 'mini-mask-loading',
                html: '保存中...'
            });
            $.ajax({
                url: "/sale/savePreAjax",
                data: { data: json,fmdata:fmjson},
                type: "post",
                success: function (text) {
                   if(text>0){
                	    mini.unmask(document.body);
						mini.alert('添加成功');
						clear();
                   }
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    alert(jqXHR.responseText);
                }
            });
        }

        function search(){
       	 var form = new mini.Form("#fm1");            
         var fmdata = form.getData();  
         var fmjson = mini.encode(fmdata); //序列化成JSON
			   mini.mask({
	               el: document.body,
	               cls: 'mini-mask-loading',
	               html: '数据加载中....'
	           }); 
	            
			
      	  $.ajax({
              url: "/sale/mycustOrderAjax",
              data: { data: fmjson },
              type: "post",
              dataType:'json',
              success: function (data) {
            	  mini.unmask(document.body);

                grid.setData(data);
                
              },
              error: function (jqXHR, textStatus, errorThrown) {
                  alert(jqXHR.responseText);
              }
          });

            }
        function clear(){
         	 grid.setData(null);
           }

    </script>

</html>